
package br.ufscar.sor.ppgccs.educatransito.entidade;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Joaquim
 */
@Entity
@Table(name = "questoes")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Questoes.findAll", query = "SELECT q FROM Questoes q"),
    @NamedQuery(name = "Questoes.findByIdQuestoes", query = "SELECT q FROM Questoes q WHERE q.idQuestoes = :idQuestoes")})
public class Questoes implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "idQuestoes")
    private Integer idQuestoes;
    @Basic(optional = false)
    @NotNull
    @Lob
    @Size(min = 1, max = 65535)
    @Column(name = "questao")
    private String questao;
    @JoinColumn(name = "idRecurso", referencedColumnName = "idRecurso")
    @ManyToOne
    private Recurso idRecurso;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idQuestoes")
    private List<Itemquestao> itemquestaoList;

    public Questoes() {
    }

    public Questoes(Integer idQuestoes) {
        this.idQuestoes = idQuestoes;
    }

    public Questoes(Integer idQuestoes, String questao) {
        this.idQuestoes = idQuestoes;
        this.questao = questao;
    }

    public Integer getIdQuestoes() {
        return idQuestoes;
    }

    public void setIdQuestoes(Integer idQuestoes) {
        this.idQuestoes = idQuestoes;
    }

    public String getQuestao() {
        return questao;
    }

    public void setQuestao(String questao) {
        this.questao = questao;
    }

    public Recurso getIdRecurso() {
        return idRecurso;
    }

    public void setIdRecurso(Recurso idRecurso) {
        this.idRecurso = idRecurso;
    }

    @XmlTransient
    public List<Itemquestao> getItemquestaoList() {
        return itemquestaoList;
    }

    public void setItemquestaoList(List<Itemquestao> itemquestaoList) {
        this.itemquestaoList = itemquestaoList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idQuestoes != null ? idQuestoes.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Questoes)) {
            return false;
        }
        Questoes other = (Questoes) object;
        if ((this.idQuestoes == null && other.idQuestoes != null) || (this.idQuestoes != null && !this.idQuestoes.equals(other.idQuestoes))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return this.questao;
    }
    
}
